
import logging
from dice import *
from baseClasses import CoordPlane

class Island(object):
    """Represents an island."""
    x = 0
    y = 0
    pirates = None
    maxPirates=-1
    treasureRoll = None
    cp = None
    
    logger = logging.getLogger('engine.PirateGame.island')
    
    def __new__(cls, boundPoints, game, treasureRoll=dice1d6, maxPirates=-1, initObjs=None):
        """
        Arguments:
        game: the game object that owns this island
        treasureRoll: A Dice object to rollSum() when a pirate tries to dig for
                        treasure. Success on rollSum() == 1
        maxPirates: The maximum number of pirates this island can hold
        initObjs: A dict of objects:point to put into this island's coordinate
                    plane. Can include triggers, animals, etc.
        """
        if initObjs == None: initObjs = {}
        self = super(Island, cls).__new__(cls)
        slef.cp = CoordPoly(boundPoints, game=game, itemLocs=initObjs)
        self.parent = game.ocean
        self.pirates = {}
        self.maxPirates=maxPirates
        self.treasureRoll = treasureRoll
    
    def findTreasure(self, pirate):
        #TODO: Implement generating treasure
        if self.treasureRoll.rollSum() == 1:
            return True
        else:
            return False
    

    